package com.wltt.product.ahuthr.service;

import com.wltt.product.ahuthr.mapper.SystemPostTypeMapper;
import com.wltt.product.ahuthr.model.ResultData;
import com.wltt.product.ahuthr.model.po.SystemPostTypePO;
import com.wltt.product.ahuthr.model.vo.QuerySystemPostTypeRsp;
import com.wltt.product.ahuthr.service.base.BaseServiceImpl;
import org.springframework.beans.BeanUtils;
import org.springframework.stereotype.Service;

import java.util.ArrayList;
import java.util.List;
import java.util.Optional;
import java.util.stream.Collectors;


/**
 * @ClassName: SystemPostTypeServiceImpl
 * @Description: 逻辑服务类<br />
 * 不做业务校验，参数校验统一放到前置的Service中
 * @Date: 2024-05-30 14:34:21
 * @Author yanggl
 */
@Service(value = "systemPostTypeService")
public class SystemPostTypeServiceImpl extends BaseServiceImpl<SystemPostTypePO, Long> implements SystemPostTypeService {

    private SystemPostTypeMapper systemPostTypeMapper;

    //构造方法
    public SystemPostTypeServiceImpl(SystemPostTypeMapper systemPostTypeMapper) {
        super(systemPostTypeMapper);
        this.systemPostTypeMapper = systemPostTypeMapper;
    }

    /**
     * 查询岗位类别
     *
     * @param
     * @return
     */
    @Override
    public ResultData querySystemPostType() {
        List<SystemPostTypePO> pos = systemPostTypeMapper.queryAll();
        List<QuerySystemPostTypeRsp> rsps = Optional.ofNullable(pos).orElse(new ArrayList<>())
                .stream().map(po -> {
                    QuerySystemPostTypeRsp rsp = new QuerySystemPostTypeRsp();
                    BeanUtils.copyProperties(po, rsp);
                    return rsp;
                }).collect(Collectors.toList());

        return ResultData.success(rsps);
    }
}